def practise(list1,list2):
    result=[]
    while list1 and list2:
        if list1[0][0]>list2[0][1]:
            list2.pop(0)
        elif list1[0][1]<list2[0][0]:
            list1.pop(0)
        else:
            if list1[0][0]>list2[0][0]:
                a=list1[0][0]
            else :
                a=list2[0][0]

            if list1[0][1] > list2[0][1]:
                b = list2[0][1]
            else :
                b = list1[0][1]
            result.append([a, b])
            if list1[0][1]<list2[0][1]:
                list1.pop(0)
            else :
                list2.pop(0)
    return result
list1=[[0,2],[5,10],[13,23],[24,25]]
list2=[[1,5],[8,12],[15,24],[25,26]]
print(practise(list1,list2))